-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustdoc: add a list of headings to the sidebar #41280
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@@ -292,7 +292,7 @@ impl Item { | |||
self.type_() == ItemType::Struct | |||
} | |||
pub fn is_enum(&self) -> bool { | |||
self.type_() == ItemType::Module | |||
self.type_() == ItemType::Enum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was so confused why enums weren't getting the sidebar stuff, until I decided to trace back through what is_enum
was doing. Apparently it's been like this for a while, but there's also no other users for this method, so it's not harming anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But now it's working correctly, which is great.
👍 |
Oh and please clean your git history. |
Can do. I'll squash when this is ready to roll, in case there's some aesthetic commentary. |
Well, please put a whitespace after |
Huh, the earlier commit failed Travis because the link-checker failed me for broken TOC links. Good job, link-checker! |
Hm is this waiting on a squash by @QuietMisdreavus or a review from @steveklabnik? |
Probably mainly on me, but I was wanting to see if there were any remarks on the "open questions" I had on the bottom of the lead comment. If @steveklabnik and @GuillaumeGomez are fine with this as-is, though, I'll squash and carry on. |
Good for me. |
Let's do it! |
6fd01ec
to
27bfbd5
Compare
@bors: r+ |
📌 Commit 27bfbd5 has been approved by |
…laumeGomez rustdoc: add a list of headings to the sidebar It's another misdreavus rustdoc PR, which means it's time for Bikeshed City once again! `:3` In an effort to aid navigation in long documentation pages, this PR adds a listing of headings to the sidebars of pages where such headings exist. For example, for structs, links to their fields, inherent methods, and trait implementations are available where applicable. Examples: * Modules/Crate roots ![image](https://cloud.githubusercontent.com/assets/5217170/25019930/1000fa3a-2052-11e7-98ff-ddf5af18b3e6.png) * Enums ![image](https://cloud.githubusercontent.com/assets/5217170/25019954/33497f9e-2052-11e7-88cf-df46f1b3b8a3.png) * Primitives ![image](https://cloud.githubusercontent.com/assets/5217170/25019978/4820bbc6-2052-11e7-8b5a-96a864eb2a5b.png) * Traits ![image](https://cloud.githubusercontent.com/assets/5217170/25020093/bd1bc9f2-2052-11e7-9cd1-00a0ad8007bc.png) * Structs ![image](https://cloud.githubusercontent.com/assets/5217170/25020145/d75206b0-2052-11e7-88cc-9e9525084775.png) Open questions: * Right now, these kinds of pages (and also unions) are the only pages that will receive the name header - pages for functions, constants, macros, etc, won't have the corresponding name in their sidebar. Should I print the name regardless and only add table-of-contents links for pages that have them? This would make them match, for example, a struct with no public fields, no methods, and no trait implementations. The latter would still have a "Struct MyStruct" line above the module contents, with no header links to speak of, whereas a function wouldn't even have "Function my\_function". * This is only a header listing, but there has been requests to include a more-complete listing of fields/methods/traits/etc, for example in rust-lang#41123.
It's another misdreavus rustdoc PR, which means it's time for Bikeshed City once again!
:3
In an effort to aid navigation in long documentation pages, this PR adds a listing of headings to the sidebars of pages where such headings exist. For example, for structs, links to their fields, inherent methods, and trait implementations are available where applicable.
Examples:
Open questions: